quartz: fix a race condition when waking up the CGRunLoop
authorMichael Natterer <mitch@gimp.org>
Fri, 11 Nov 2011 22:49:21 +0000 (23:49 +0100)
committerMichael Natterer <mitch@gimp.org>
Fri, 11 Nov 2011 22:58:43 +0000 (23:58 +0100)
Wake up the run loop unconditionally (don't check if it is waiting) because
it might go into waiting state right after we checked for it. Fixes GIMP
startup (which has a lot of GIOChannel I/O but zero NSEvents) from several
minutes to a few seconds.
(cherry picked from commit 0729cdc9a1e8003c41d3ebf20eecfe2d1b29ffbe)

gdk/quartz/gdkeventloop-quartz.c

index 702238c089ebec1e3280a9424f3e3b9a3f83f026..4181a5de2498b247508c28433fcd1790f361f3f3 100644 (file)
@@ -207,9 +207,12 @@ signal_main_thread (void)
    */
   if (!run_loop_polling_async)
     CFRunLoopSourceSignal (select_main_thread_source);
-  
-  if (CFRunLoopIsWaiting (main_thread_run_loop))
-    CFRunLoopWakeUp (main_thread_run_loop);
+
+  /* Don't check for CFRunLoopIsWaiting() here because it causes a
+   * race condition (the loop could go into waiting state right after
+   * we checked).
+   */
+  CFRunLoopWakeUp (main_thread_run_loop);
 }
 
 static void *